<template>
  <div class="box_age">
    <div class="title">
      <p>年龄比例</p>
      <img src="../../images/dataScreen-title.png" alt="">
    </div>
    <div class="charts" ref="charts"></div>
  </div>
</template>
<script setup lang='ts' name='age'>
import * as echarts from 'echarts'
import { onMounted, ref } from 'vue';
let charts = ref()
onMounted(() => {
  let mycharts = echarts.init(charts.value)
  let option = {
    title:{
      text:'本日总数',
      textStyle:{
        color:'white',
        fontSize:15,
      },
      top:120,
      left:210,
    },
    tooltip: {
      trigger: 'item'
    },
    legend: {//图例组件
      top: 30,
      right: 10,
      orient: 'vertical',//组件方向
      textStyle: {
        color: "white",
        fontSize: 14
      }
    },
    series: [
      {
        name: '年龄',
        type: 'pie',
        radius: ['40%', '70%'],
        avoidLabelOverlap: false,
        itemStyle: {
          borderRadius: 10,
          borderColor: '#fff',
          borderWidth: 2
        },
        label: {
          show: true,
          position: 'inside',
          color:'white',
          formatter:'{d}%',
        },
        // emphasis: {放大效果
        //   label: {
        //     show: true,
        //     fontSize: 40,
        //     fontWeight: 'bold'
        //   }
        // },
        labelLine: {
          show: true,      
        },
        data: [
          { value: 160, name: '10岁以下' },
          { value: 80, name: '10-18岁' },
          { value: 120, name: '18-30岁' },
          { value: 240, name: '30-40岁' },
          { value: 200, name: '40-60岁' },
          { value: 200, name: '60岁以上' },
        ]
      }
    ],
    grid: {
      left: 0,
      right: 0,
      top: 0,
      bottom: 0,
    }
  };
  mycharts.setOption(option)
})


</script>


<style scoped scss>
.box_age {
  width: 100%;
  height: 100%;
  background: url(../../images/dataScreen-main-cb.png) no-repeat;
  background-size: 100% 100%;
  margin: 20px 0px;

  .title {
    color: white;
    font-size: 20px;
    margin-left: 20px;
  }

  .charts {
    height: 260px;
  }
}
</style>